package com.smbms.controller.commonality;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.smbms.pojo.system.Og_User;
import com.smbms.service.commonality.CommonalityService;
import com.smbms.util.Tool;

@Controller
public class Login {
	@Autowired
	private CommonalityService cs;
	
	@RequestMapping("/login.html")
	public String login(@RequestParam String user_code,@RequestParam String user_password,HttpServletRequest request) {
		Og_User user = cs.loginUser(user_code, user_password);
		if(user!=null) {
			request.getSession().setAttribute(Tool.USER_SESSION, user);
			return "index";
		}else {
			request.setAttribute("error", "�û������������");
			return "forward:login.jsp";
		}
		
	}
	@RequestMapping("/first.html")
	public String firsts() {
		System.out.println("进first.html");
		return "commonality/first";
	}
}
